let arr = [5, 2, 1, -10, 8];

function compareDec(a, b) {
    if (a < b) {
        return 1;
    } else if (a == b) {
        return 0;
    } else {
        return -1;
    }
}

arr.sort(compareDec);

alert(arr);